const state = {
    isCollapse: false,
    selectMenu: []
}

const mutations = {
    collapseMenu (state) {
        state.isCollapse = !state.isCollapse
    },
    addMenu (state, payload) {
        // 添加未有的菜单
        if(state.selectMenu.findIndex(item => item.path === payload.path) === -1){
            state.selectMenu.push(payload)
        }
    },
    closeTab (state, payload){
        // 找到tab对应的下标
        const index = state.selectMenu.findIndex(item => item.path === payload.path)
        // 通过下标删除数组元素
        state.selectMenu.splice(index, 1)
    }
}

export default {
    state,
    mutations
}